using Microsoft.AspNetCore.Mvc;
using ZR.Model.ProdManage.Dto;
using ZR.Model.ProdManage;
using ZR.Service.ProdManage.IProdManageService;
using ZR.Admin.WebApi.Filters;

//创建时间：2025-05-18
namespace ZR.Admin.WebApi.Controllers.ProdManage
{
    /// <summary>
    /// 二级包装明细
    /// </summary>
    [Verify]
    [Route("ProdManage/ProdTwoPackDetail")]
    public class ProdTwoPackDetailController : BaseController
    {
        /// <summary>
        /// 二级包装明细接口
        /// </summary>
        private readonly IProdTwoPackDetailService _ProdTwoPackDetailService;

        public ProdTwoPackDetailController(IProdTwoPackDetailService ProdTwoPackDetailService)
        {
            _ProdTwoPackDetailService = ProdTwoPackDetailService;
        }

        /// <summary>
        /// 查询二级包装明细列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("pageList")]
        [ActionPermissionFilter(Permission = "prod:twoPackDetail:list")]
        public IActionResult PageProdTwoPackDetail([FromQuery] ProdTwoPackDetailQueryDto parm)
        {
            var response = _ProdTwoPackDetailService.GetPageList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询二级包装明细详情
        /// </summary>
        /// <param name="DetailId"></param>
        /// <returns></returns>
        [HttpGet("{DetailId}")]
        [ActionPermissionFilter(Permission = "prod:twoPackDetail:query")]
        public IActionResult GetProdTwoPackDetail(string DetailId)
        {
            var response = _ProdTwoPackDetailService.GetInfo(DetailId);
            
            var info = response.Adapt<ProdTwoPackDetailDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加二级包装明细
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "prod:twoPackDetail:add")]
        [Log(Title = "二级包装明细", BusinessType = BusinessType.INSERT)]
        public IActionResult AddProdTwoPackDetail([FromBody] ProdTwoPackDetailDto parm)
        {
            var modal = parm.Adapt<ProdTwoPackDetail>().ToCreate(HttpContext);

            var response = _ProdTwoPackDetailService.AddProdTwoPackDetail(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新二级包装明细
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "prod:twoPackDetail:edit")]
        [Log(Title = "二级包装明细", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateProdTwoPackDetail([FromBody] ProdTwoPackDetailDto parm)
        {
            var modal = parm.Adapt<ProdTwoPackDetail>().ToUpdate(HttpContext);
            var response = _ProdTwoPackDetailService.UpdateProdTwoPackDetail(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除二级包装明细
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete")]
        [ActionPermissionFilter(Permission = "prod:twoPackDetail:delete")]
        [Log(Title = "二级包装明细", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteProdTwoPackDetail([FromBody] string[] ids)
        {
            return ToResponse(_ProdTwoPackDetailService.Delete(ids));
        }

    }
}